# $Id$
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: William Rea <sillywilly@gmail.com>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - patch to increase build timeout

pkgname=maven
pkgver=3.3.3
pkgrel=2
pkgdesc="A Java project management and project comprehension tool"
arch=('any')
url="http://maven.apache.org"
license=('APACHE')
depends=('java-environment')
makedepends=('apache-ant')
backup=('opt/maven/conf/settings.xml')
source=(http://apache-mirror.rbc.ru/pub/apache/maven/maven-3/$pkgver/source/apache-maven-$pkgver-src.tar.gz
	maven.sh
        timeout.patch)
md5sums=('e1db3821aa39d4b98178f68467894342'
         '5ed0bddbf5c5375fe5032a76a9506426'
         'b44156dc845e23c220a99bf0e110ff48')

package() {
  cd $srcdir/apache-maven-$pkgver

  patch -p1 -i ../timeout.patch

  . /etc/profile.d/jre.sh
#  . /etc/profile.d/jdk.sh

  mkdir -p $srcdir/repo
  mkdir $pkgdir/opt
  export MAVEN_OPTS=-Xmx512m
  export M2_HOME=$pkgdir/opt/maven
  export PATH=$PATH:$M2_HOME/bin

  # FIXME: downloads many deps from Internet. Probably they should be
  # packaged or added into source=()
  ant -Dmaven.repo.local=$srcdir/repo
  install -D -m 755 $srcdir/maven.sh $pkgdir/etc/profile.d/maven.sh
  rm $pkgdir/opt/maven/*.txt
  mkdir -p $pkgdir/usr/bin
  ln -s /opt/maven/bin/mvn $pkgdir/usr/bin/mvn
  ln -s /opt/maven/bin/mvnDebug $pkgdir/usr/bin/mvnDebug
}
